<?php

class Application_Model_Student {

    /**
     * 
     * @param type $intStudentID
     */
    public function getStudentDetail($intStudentID) {
        try {
            $dbAdapter = Zend_Registry::get('dbAdapter');
            $stmt = $dbAdapter->query("SELECT * FROM Student WHERE id='$intStudentID'");
            $arrResult = $stmt->fetchAll();
        } catch (Exception $exc) {
            echo $exc->getTraceAsString();
        }
        return $arrResult;
    }

    /**
     * 
     */
    public function getStudentList() {
        try {
            $dbAdapter = Zend_Registry::get('dbAdapter');
            $stmt = $dbAdapter->query('SELECT * FROM Student');
            $arrResult = $stmt->fetchAll();
        } catch (Exception $exc) {
            echo $exc->getTraceAsString();
        }
        return $arrResult;
    }

    /**
     * 
     * @param type $arrStudent
     */
    public function insertStudent($arrStudentInfo) {
        try {
            $dbAdapter = Zend_Registry::get('dbAdapter');
            $dbAdapter->insert('Student', $arrStudentInfo);
        } catch (Exception $exc) {
            echo $exc->getTraceAsString();
        }
    }

    /**
     * 
     * @param type $arrStudent
     * @param type $intStudentID
     */
    public function updateStudent($arrStudent, $intStudentID) {
        try {
            $dbAdapter = Zend_Registry::get('dbAdapter');
            $dbAdapter->update("Student", $arrStudent, "id='$intStudentID'");
        } catch (Exception $exc) {
            echo $exc->getTraceAsString();
        }
    }

    /**
     * 
     * @param type $intStudentID
     */
    public function deleteStudent($intStudentID) {
        try {
            $dbAdapter = Zend_Registry::get('dbAdapter');
            $dbAdapter->delete('Student', 'id=' . $intStudentID);
        } catch (Exception $exc) {
            echo $exc->getTraceAsString();
        }
    }

}
